package org.cqu_proj.demo.entity;

import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.List;

@Document(collection = "user_features")  // 指定MongoDB集合名称
public class UserFeatures {

    @Id
    private ObjectId id;  // MongoDB的文档ID
    @Field("userId")
    private int userId;
    @Field("feature_0")
    private double feature0;
    @Field("feature_1")
    private double feature1;

    @Field("feature_2")
    private double feature2;

    @Field("feature_3")
    private double feature3;

    @Field("feature_4")
    private double feature4;

    @Field("feature_5")
    private double feature5;

    @Field("feature_6")
    private double feature6;

    @Field("feature_7")
    private double feature7;

    @Field("feature_8")
    private double feature8;

    @Field("feature_9")
    private double feature9;

    @Field("feature_10")
    private double feature10;

    @Field("feature_11")
    private double feature11;

    @Field("feature_12")
    private double feature12;

    @Field("feature_13")
    private double feature13;

    @Field("feature_14")
    private double feature14;

    @Field("feature_15")
    private double feature15;

    @Field("feature_16")
    private double feature16;

    @Field("feature_17")
    private double feature17;

    @Field("feature_18")
    private double feature18;

    @Field("feature_19")
    private double feature19;
    @Field("selectGenre")
    private boolean selectGenre=false;



    // <editor-fold desc="getter and setter">

    public boolean isSelectGenre() {
        return selectGenre;
    }

    public void setSelectGenre(boolean selectGenre) {
        this.selectGenre = selectGenre;
    }

    public ObjectId getId() {
        return id;
    }

    public void setId(ObjectId id) {
        this.id = id;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public double getFeature1() {
        return feature1;
    }

    public void setFeature1(double feature1) {
        this.feature1 = feature1;
    }

    public double getFeature2() {
        return feature2;
    }

    public void setFeature2(double feature2) {
        this.feature2 = feature2;
    }

    public double getFeature3() {
        return feature3;
    }

    public void setFeature3(double feature3) {
        this.feature3 = feature3;
    }

    public double getFeature4() {
        return feature4;
    }

    public void setFeature4(double feature4) {
        this.feature4 = feature4;
    }

    public double getFeature5() {
        return feature5;
    }

    public void setFeature5(double feature5) {
        this.feature5 = feature5;
    }

    public double getFeature6() {
        return feature6;
    }

    public void setFeature6(double feature6) {
        this.feature6 = feature6;
    }

    public double getFeature7() {
        return feature7;
    }

    public void setFeature7(double feature7) {
        this.feature7 = feature7;
    }

    public double getFeature8() {
        return feature8;
    }

    public void setFeature8(double feature8) {
        this.feature8 = feature8;
    }

    public double getFeature9() {
        return feature9;
    }

    public void setFeature9(double feature9) {
        this.feature9 = feature9;
    }

    public double getFeature10() {
        return feature10;
    }

    public void setFeature10(double feature10) {
        this.feature10 = feature10;
    }

    public double getFeature11() {
        return feature11;
    }

    public void setFeature11(double feature11) {
        this.feature11 = feature11;
    }

    public double getFeature12() {
        return feature12;
    }

    public void setFeature12(double feature12) {
        this.feature12 = feature12;
    }

    public double getFeature13() {
        return feature13;
    }

    public void setFeature13(double feature13) {
        this.feature13 = feature13;
    }

    public double getFeature14() {
        return feature14;
    }

    public void setFeature14(double feature14) {
        this.feature14 = feature14;
    }

    public double getFeature15() {
        return feature15;
    }

    public void setFeature15(double feature15) {
        this.feature15 = feature15;
    }

    public double getFeature16() {
        return feature16;
    }

    public void setFeature16(double feature16) {
        this.feature16 = feature16;
    }

    public double getFeature17() {
        return feature17;
    }

    public void setFeature17(double feature17) {
        this.feature17 = feature17;
    }

    public double getFeature18() {
        return feature18;
    }

    public void setFeature18(double feature18) {
        this.feature18 = feature18;
    }

    public double getFeature19() {
        return feature19;
    }

    public void setFeature19(double feature19) {
        this.feature19 = feature19;
    }

    public double getFeature0() {
        return feature0;
    }

    public void setFeature0(double feature0) {
        this.feature0 = feature0;
    }
    // </editor-fold>
    public UserFeatures() {
    }
    public UserFeatures(int userId, List<Double> featureArray) {
        this.userId = userId;
        if (featureArray != null && featureArray.size() == 20) {
            for (int i = 0; i < 20; i++) {
                // 使用反射来给字段赋值
                try {
                    this.getClass().getDeclaredField("feature" + i).set(this, featureArray.get(i));
                } catch (NoSuchFieldException | IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
        this.selectGenre=false;
    }
    //默认构造
    public UserFeatures(int userId) {
        double i=1;
        this.userId = userId;
        this.feature1 = i;
        this.feature2 = i;
        this.feature3 = i;
        this.feature4 = i;
        this.feature5 = i;
        this.feature6 = i;
        this.feature7 = i;
        this.feature8 = i;
        this.feature9 = i;
        this.feature10 = i;
        this.feature11 = i;
        this.feature12 = i;
        this.feature13 = i;
        this.feature14 = i;
        this.feature15 = i;
        this.feature16 = i;
        this.feature17 = i;
        this.feature18 = i;
        this.feature19 = i;
        this.feature0 = i;
    }
}
